package cn.xz.zysjz.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.util.ArrayList;
import java.util.Objects;

import cn.xz.zysjz.R;
import cn.xz.zysjz.bean.CommonLib;
import cn.xz.zysjz.bean.UserBean;
import cn.xz.zysjz.bean.YyBean;
import cn.xz.zysjz.utils.SessionUtils;

/**
 * 预约记录适配器*/
public class HisListAdapter extends BaseQuickAdapter<YyBean, BaseViewHolder> {

    public HisListAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, YyBean mData) {
        TextView tv1 = helper.findView(R.id.tv1);
        TextView tv2 = helper.findView(R.id.tv2);
        TextView tv3 = helper.findView(R.id.tv3);
        TextView tv4 = helper.findView(R.id.tv4);
        TextView tv5 = helper.findView(R.id.tv5);
        TextView tv6 = helper.findView(R.id.tv6);
        TextView tv7 = helper.findView(R.id.tv7);
        TextView tv8 = helper.findView(R.id.tv8);
        TextView tv9 = helper.findView(R.id.tv9);
        //选择的疫苗
        tv1.setText("疫苗种类: " + mData.getActivityListBean().getName());
        //作用
        tv2.setText("疫苗作用: " + mData.getActivityListBean().getMsg());
        //接种点
        tv3.setText("接种点地址: " + mData.getIndexBean().getAddress());
        //联系方式
        tv4.setText("接种点联系方式: " + mData.getIndexBean().getPhone());
        //负责医生
        tv5.setText("负责医生: " + mData.getIndexBean().getName());
        //剩余
        tv6.setText("当前疫苗剩余: " + mData.getIndexBean().getNumber() + "支/人");
        //是否免费
        String m = "自行前往接种点进行付费";
        if (mData.getActivityListBean().getFree()){
            m = "免费接种";
        }
        tv7.setText("是否免费: " + m);
        //用户名
        if (CommonLib.nowUserBean != null){
            tv8.setText("预约用户: " + CommonLib.nowUserBean.getName());
        }else {
            tv8.setText("预约用户: 游客");
        }
        //手机号
        String mP = "用户手机号: 未绑定";
        if (!Objects.equals(SessionUtils.getString(CommonLib.USER_PHONE, ""), "")){
            mP = "用户手机号: " + SessionUtils.getString(CommonLib.USER_PHONE, "");
        }
        tv9.setText(mP);
    }
}
